package tsb.com.html5.controller.base;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.cloudfoundry.runtime.env.ApplicationInstanceInfo;
import org.cloudfoundry.runtime.env.CloudEnvironment;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.web.context.ConfigurableWebApplicationContext;

public class Initializer implements
ApplicationContextInitializer<ConfigurableWebApplicationContext> {

	protected final Log logger = LogFactory.getLog(getClass());

	public void initialize(ConfigurableWebApplicationContext ctx) {
		ConfigurableEnvironment environment = ctx.getEnvironment();

		/*ApplicationInstanceInfo instanceInfo = new CloudEnvironment()
		.getInstanceInfo();
		if (instanceInfo == null) {
			// We are running locally.
			System.out.println(">>>>>>>>> Setting default profile.");
			environment.setActiveProfiles("default");
		} else {
			// We are running in the cloud.
			System.out.println(">>>>>>>>> Setting cloud profile.");
			environment.setActiveProfiles("cloud");
		}*/
		
		logger.debug(">>>>>>>>> Initializer - Setting default profile <<<<<<<<<<<");
		environment.setActiveProfiles("default");
		
	}
}
